home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / NeoIntroTCL3.0 folder / TCL / NeoBench / Includes / CNeoBenchDoc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-14  |  2.5 KB  |  93 lines  |  [TEXT/KAHL]

  1. /****
  2.  * CNeoBenchDoc.h
  3.  *
  4.  *    Document class for a typical application.
  5.  *
  6.  ****/
  7. #pragma once            /* Include this file only once */
  8.  
  9. #include "NeoBench.h"
  10. #include "CFiller.h"
  11. #include CNeoPersistH
  12. #include <Timer.h>
  13.  
  14. #include CNeoDocNativeH
  15.  
  16. #ifndef qNeoPersist
  17. class CNeoIndexIterator;
  18. #endif
  19.  
  20. #ifdef qNeoThreads
  21. #include CNeoThreadNativeH
  22.  
  23. class CNeoBenchDoc;
  24.  
  25. typedef enum {
  26.     kDie,
  27.     kAlive
  28. } health;
  29.  
  30. #define kMaxThreads        5
  31.  
  32. typedef struct {
  33.     short                phase;        /* Phase of work being done                */
  34.     health                state;        /* Healthiness of this thread            */
  35.     CNeoBenchDoc *        document;    /* Document this thread is working for    */
  36.     CNeoThreadNative *    thread;        /* Pointer to thread                    */
  37. } ThreadInfo;
  38.  
  39. class CBenchThread : public CNeoThreadNative
  40. {
  41. public:
  42.                         CBenchThread(ThreadInfo *aInfo, const NeoThreadType aType = kNeoCoopThread, void **aArg = nil, const Size aStackSize = 0, const NeoThreadOptions aOptions = (kUsePremadeThread + kCreateIfNeeded));
  43.     virtual long        run(void);
  44.  
  45.     virtual void        handleSwapIn(void);
  46.     virtual void        handleSwapOut(void);
  47.  
  48. protected:
  49.     Boolean                fSetTimer;
  50.     TMTask                fTimer;
  51.     ThreadInfo *        fInfo;
  52. };
  53. #endif
  54.  
  55. typedef CNeoDocNative        CNeoBenchDocBase;
  56.  
  57. class CNeoBenchDoc : public CNeoBenchDocBase {
  58. public:
  59.                         // Construction/Destruction
  60.                         CNeoBenchDoc(const Boolean aPrintable, const Boolean aNewFile, const Boolean aRemote);
  61.     virtual void        buildWindow(void);
  62.     virtual Boolean        Close(Boolean aQuitting);
  63.     virtual void        DoCommand(long theCommand);
  64.     virtual void        NewFile(void);
  65.     virtual void        OpenFile(SFReply *macSFReply);
  66.  
  67.                         // Filing
  68.     virtual void        Dawdle(long *maxSleep);
  69.     void                doSomeWork(const short aPhase, TMTask *aTimer);
  70.     void                getTargetTotals(void);
  71. #ifdef qNeoThreads
  72.     void                killThreads(void);
  73. #endif
  74.     virtual void        ProviderChanged(CCollaborator *aProvider, long reason, void* info);
  75.     void                setPhase(const short aPhase);
  76.     Boolean                getState(void);
  77.     void                setState(const Boolean aState);
  78.  
  79.     NeoPhase            fPhaseInfo[kMaxPhase +1];    // The main phases
  80.     Boolean                fState;                        // Running state
  81.     Boolean                fRefresh;                    // Update stats on screen
  82.     short                fPhase;                        // The current phase
  83. #ifdef qNeoThreads
  84.     short                fThreadCount;                // Current number of slave threads
  85.     ThreadInfo            fThreadInfo[kMaxThreads];    // Info used by each thread
  86. #endif
  87. #ifndef qNeoPersist
  88.     CNeoIndexIterator *    fIterator;                    // For traversing index of objects
  89. #endif
  90.     CFiller *            fObject;                    // Object pointer for serially finding objects
  91.     long                col_value[3];                // 3 columns - soFar, PerRecord, Total
  92.     short                col_index;                    // Index into the column
  93. };